<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>20210105</title>
    <script src="./jquery1.9/jquery-1.9.0.min.js"></script>
    <style>
        .container {
            width: 860px;
            margin: 10px auto;
        }
        .products {
            display: flex;
            flex-wrap: wrap;
            flex-direction: row;
        }
        .item {
            border: 1px solid black;
            width: 200px;
            height: 200px;
            margin: 5px;
        }
        .item > .img {
            height: 150px;
            overflow: hidden;
        }
        .img > img {
            width: 100%;
        }
        .item .desc {
            padding: 5px;
        }
        .item .ac:after {
            content: '';
            clear: both;
            display: block;
        }
        .item .ac .p {
            float: left;
        }
        .item .ac .add {
            float: right;
        }
        .page {
            margin-top: 10px;
            text-align: center;
        }
        .page > a {
            font-size: 24px;
            background-color: #00c0ff;
            color: white;
            padding: 10px;
            text-decoration: none;
            margin: 0 5px;
        }
    </style>

    <script>
        function doSome(){
            var p1=$("#f").serialize();
            console.log(p1);
            var option={
                type:"post",
                url:"./service/hqq0105.php",
                data:p1,
                dataType:"json",
                success:function(result){
                    console.log(result);
                    $("#img").attr("src",`${result['p_image_url']}`);
                    $("#p_name").html(`${result['p_name']}`);
                    $(".p").html(`${result['p_price']}`);
                },
                error:function(jqXHR,textStatus,errorThrown){
                    console.log(jqXHR);
                    console.log(textStatus);
                    console.log(errorThrown);
                },
                async:true,
                complete:function(jqXHR,textStatus){
                    console.log('查询完成');
                }
            }
            $.ajax(option);
        }
    </script>
</head>
<body>
    <div class="container" >
        <div>
            <form id="f">
                <div>
                    <label>商品编号:<input type="text" name="id" ></label>
                    <label>商品名称:<input type="text" name="name" ></label>
                </div>
                <div>
                    <label>商品价格:<input type="text" name="begin" > ~ <input type="text" name="end" ></label>
                </div>
                <div>
                    <input type="button" value="search" onclick="doSome()" />
                </div>
            </form>
        </div>
        <div class="products" >

            <div class="item" >
                <div class="img" >
                    <img id="img" src="" alt="no image">
                </div>
                <div class="desc" >
                    <div><a id="p_name" href="javascript:;">p_name</a></div>
                    <div class="ac" >
                        <span class="p" >p_price</span>
                        <a href="javascript:;" class="add" >加入购物车</a>
                    </div>
                </div>
            </div>

        </div>

        <div class="page" >
            <a href="javascript:;">上一页</a>
            <a href="javascript:;">3</a>
            <a href="javascript:;">下一页</a>
        </div>
    </div>
</body>
</html>